package com.four.dailymanage.dish.dao;


import com.four.dailymanage.dish.entity.PayTotal;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface PayTotalDao {
    @Select("<script>" +
            "SELECT * FROM pay_total" +
            "  <where>" +
            "    <if test=\"startDate != null and endDate != null\">" +
            "      and DATE(payDt) between #{startDate} and #{endDate}" +
            "    </if>" +
            "    <if test=\" accountName != null\">" +
            "       and accountName = #{accountName} " +
            "    </if>" +
            "</where>"+
            "limit #{start},#{size}"+
            "</script>")
    public List<PayTotal> getPayTotalByCon(int start, int size,String startDate,String endDate,String accountName );
    @Select("<script>" +
            "SELECT count(*) FROM pay_total" +
            "  <where>" +
            "    <if test=\"startDate != null and endDate != null\">" +
            "      and DATE(payDt) between #{startDate} and #{endDate}" +
            "    </if>" +
            "    <if test=\" accountName != null\">" +
            "       and accountName = #{accountName} " +
            "    </if>" +
            "</where>"+
            "</script>")
    public  int countPayTotal(String startDate,String endDate,String accountName);

    /**
     * 批量导出用到的列表 有条件和无条件
     * @param startDate
     * @param endDate
     * @param accountName
     * @return
     */
    @Select("<script>" +
            "SELECT * FROM pay_total" +
            "  <where>" +
            "    <if test=\"startDate != null and endDate != null\">" +
            "      and DATE(payDt) between #{startDate} and #{endDate}" +
            "    </if>" +
            "    <if test=\" accountName != null\">" +
            "       and accountName = #{accountName} " +
            "    </if>" +
            "</where>"+
            "</script>")
    public List<PayTotal> getPayT(String startDate,String endDate,String accountName);

    @Select("<script>" +
            "  select * from pay_total where id in" +
            "  <foreach collection=\"idsArr\" item=\"did\" open=\"(\" close=\")\" separator=\",\">" +
            "    #{did}" +
            "   </foreach>" +
            "</script>")
    public List<PayTotal> getRowsPayT(List<Integer> idsArr);
}
